import request from '@/common/utils/request'

export const getSalarysListApi = (params) => {
    return request({
        url: '/salarys/list',
        method: 'GET',
        params
    })
}


/**
 * 批量-导出工资月份报表
 * @returns
 */
export const getSalarysHistorysExportApi = (params) => {
    return request({
        url: `/salarys/historys/${params.yearMonth}/export`,
        method: 'GET',
        // 改变接收数据的类型
        responseType: 'blob', // 使用 blob 接收二进制文件流
        params
    })
}

/**
 * 获取企业计薪及津贴设置
 * @returns
 */
export const getSalarysSettingsApi = () => {
    return request({
        url: '/salarys/settings',
        method: 'GET',
    })
}

/**
 * 查询用户薪资
 * @returns
 */
export const getSalarysModifyIdApi = (params) => {
    return request({
        url: `/salarys/modify/${params.userId}`,
        method: 'GET',
        params
    })
}

/**
 * 获取企业是否设置当月工资
 * @returns
 */
export const getSalarysCompanySettingsApi = () => {
    return request({
        url: '/salarys/company-settings',
        method: 'GET'
    })
}

/**
 * 根据年月查询企业用户薪资列表
 * @returns
 */
export const getSalarysReportsApi = (params) => {
    return request({
        url: `/salarys/reports/${params.yearMonth}`,
        method: 'GET',
        params
    })
}

/**
 * 保存企业计薪及津贴设置
 * @returns
 */
export const postSalarysSettingsApi = (data) => {
    return request({
        url: '/salarys/settings',
        method: 'POST',
        data
    })
}

/**
 * 工资数据归档
 * @returns
 */
export const postSalarysHistorysDataArchive = (params) => {
    return request({
        url: `/salarys/historys/${params.yearMonth}/archive`,
        method: 'POST',
        params
    })
}

/**
 * 调薪
 * @returns
 */
export const postSalarysModifyIdApi = (data) => {
    return request({
        url: `/salarys/modify/${data.userId}`,
        method: 'POST',
        data
    })
}

/**
 * 员工定薪
 * @returns
 */
export const postSalarysInitIdApi = (data) => {
    return request({
        url: `/salarys/init/${data.userId}`,
        method: 'POST',
        data
    })
}


/**
 * 新建考勤报表
 * @returns
 */
export const putSalarysReportsReportsApi = (params) => {
    return request({
        url: `/salarys/reports/${params.yearMonth}/newReport`,
        method: 'PUT',
        params
    })
}